package com.yq.cp.controller.data;

import com.yq.cp.entity.common.ApiResult;
import com.yq.cp.entity.data.dto.IndexDayAllDataDto;
import com.yq.cp.entity.data.dto.IndexSqlDataViewDto;
import com.yq.cp.entity.data.vo.IndexDataByCompanyVo;
import com.yq.cp.entity.data.vo.IndexDataViewVo;
import com.yq.cp.entity.data.vo.IndexDayAllDataVo;
import com.yq.cp.service.data.IndexService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 大数据接口
 * </p>
 *
 * @author shen
 * @since 2023-06-10
 */

@RestController
@RequestMapping("/index")
public class IndexController {

    @Resource
    private IndexService indexService;


    /**
     * 获取能源数据
     * @param val
     * @return
     */
    @PostMapping("/dayAllData")
    public ApiResult dayAllData(@RequestBody IndexDayAllDataVo val){
        List<IndexDayAllDataDto> list = indexService.dayAllDate(val);
        return ApiResult.success(list);
    }


    /**
     * 获取公司/能源站能源数据
     * @param val
     * @return
     */
    @PostMapping("/dataByCompany")
    public ApiResult dataByCompany(@RequestBody IndexDataByCompanyVo val){
        Map<String, Object> map = indexService.dataByCompany(val);
        return ApiResult.success(map);
    }


    /**
     * 能源视图接口
     * @param val
     * @return
     */
    @PostMapping("/dataView")
    public ApiResult dataView(@RequestBody IndexDataViewVo val){
        List<IndexSqlDataViewDto> list = indexService.dataView(val);
        return ApiResult.success(list);
    }


}
